package com.bltec.emergency.mapper;


import com.bltec.emergency.model.Laws;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface LawsMapper {
    //插入一条Laws记录
    @Insert("insert into laws (laws_and_regulations,standard_specification,file_name,file_href," +
            "create_by,create_time,enable) " +
            "values(#{lawsAndRegulations},#{standardSpecification},#{fileName},#{fileHref},#{createBy},#{createTime},#{enable})")
    boolean insert(Laws laws);

    //通过id设置一条记录为不可用
    @Update("update laws set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update laws set laws_and_regulations=#{lawsAndRegulations},standard_specification=#{standardSpecification},file_name=#{fileName}," +
            "file_href=#{fileHref},update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateLawsById(Laws laws);

    //查找符合id字段的记录
    @Select("select id,laws_and_regulations,standard_specification,file_name,file_href,create_by,create_time,update_by,update_time,enable" +
            " from laws where id =#{id} and enable=1")
    Laws getLawsById(Long id);

    //查找所有记录
    @Select("select id,laws_and_regulations,standard_specification,file_name,file_href,create_by,create_time,update_by,update_time,enable" +
            " from laws where enable=1")
    List<Laws> selectAll();
}